//
//  THJTradeDetailVC.m
//  THJXHW
//
//  Created by 河南德艺 on 2018/8/10.
//  Copyright © 2018年 河南德艺. All rights reserved.
//

#import "THJTradeDetailVC.h"
#import "THJTradeDetailCell.h"

@interface THJTradeDetailVC ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView * _tableview;
    NSArray * listArr;
}
@end

@implementation THJTradeDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getData];
    [self SVHUDShow];
    if(KIsiPhoneX){
        [self setXNavBarWithTitle:@"交易明细"];
    }else{
        [self setNavBarWithTitle:@"交易明细"];
    }
   
}
-(void)setTableview{
    _tableview = [self setTableviewWithFrame:CGRectMake(0, NavbarHeight, ScreenWidth, ScreenHeight-NavbarHeight) RegisterNibNameArr:@[@"THJTradeDetailCell"] ReuseIdentifierArr:@[@"cell"] RowHeight:255 BgColor:[UIColor whiteColor] IsLoadMore:NO];
    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return listArr.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    THJTradeDetailCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    NSDictionary * dic = listArr[indexPath.row];
    [cell setContent:dic];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
//15836313772
-(void)getData{
    NSString * mobile = [RSA encryptString:[THJTools getMobile] publicKey:RSA_PubKey];
    NSLog(@"phonekk-%@",[THJTools getMobile]);
    [THJNetWork postNetDataFromUrl:@"http://p.thjb.net/thjblink/appdata.php?action=hjb_jy_list" parameters:@{@"mobile":mobile,@"type":@"ios"} callback:^(NSDictionary *  receiveData, NSError *error) {
        [self SVHUDHiden];
        NSLog(@"账号信息--%@",receiveData);
        [self SVHUDHiden];
        if([receiveData[@"status"] isEqual:@"success"]){
            if([receiveData[@"data"][@"list"] isKindOfClass:[NSArray class]]){
                NSLog(@"llll-4");
                listArr = [[receiveData[@"data"][@"list"] reverseObjectEnumerator] allObjects];
                [self setTableview];
            }else{
                [self HUDShowMsg:@"无交易明细" AfterDelayDimiss:2];
                NSLog(@"llll-0");
            }
        }else{
            [self HUDShowMsg:@"获取信息失败" AfterDelayDimiss:1];
        }
    }];
}
@end
